#ifndef ARCHPAGER_H_
#define ARCHPAGER_H_

/*
 *
 */
#include <Object.h>

#include <kiddie/kiddie.h>
#include <sys/types.h>
#include <arch/mach/platform.h>
#include <arch/platform.h>

namespace kernel {
namespace mem {
namespace page {

/**
 * memory
 */
class MemArea
{
public:
	MemArea() {}
	MemArea(vaddr_t v,size_t l) : v_addr(v), length(l) {}
	MemArea(paddr_t p, vaddr_t v,size_t l) : p_addr(p), v_addr(v), length(l) {}
	~MemArea() {}
	MemArea *prev;
	MemArea *next;
	vaddr_t v_addr;	/* virtual address */
	size_t length;	/* length in bytes */
	vaddr_t p_addr;	/* phys address of area */
};

class VmMap {
public:
	MemArea areas;
	pgd_t	pgd;

public:
	VmMap () {}
	VmMap(PageFactory *);
	VmMap(PageFactory *, pgd_t);
	VmMap(const VmMap& _from);
	VmMap(VmMap& _from);
	~VmMap() {}
	int normalize (void);
	int normalize (MemArea *);
	int add(vaddr_t, size_t);
	int doPgd (void);
	vaddr_t mmap(paddr_t, size_t);
	vaddr_t mmap(paddr_t, vaddr_t, size_t);
	VmMap &operator= (VmMap &_from);

private:
	PageFactory *pNode;
	pgd_t __alloc_pgd(void);
};


}
}
}

#endif /*ARCHPAGER_H_*/
